//请求方法
import axios from "axios";
import base from "./base";

//注意登录接口是post请求，拿参应该如下  post先接收对象，必须为json格式（字符串拼接格式）
// const qs = require("querystring")  改写法以弃用
import qs from "qs"

const api = {
  //登录接口
  getLogin(params) {
    //注意此时的params还是一个对象  里面有的字段为params={username:"",password:""}
    console.log(params,qs.stringify(params));
    return axios.post(base.Login, qs.stringify(params));
  },
  //商品列表数据
  getGoodsList(params) {
    return axios.get(base.goodList, {
      params, //返回{page:xxx}
    });
  },
  //搜索列表数据
  getSearch(params) {
    return axios.get(base.search, {
      params, //返回{search:xxx}
    });
  },
  getSelectCategory(params) {
    return axios.get(base.selectCategory, {
      params, //返回{search:xxx}
    });
  },
  getAddGoods(params) {
    return axios.get(base.addGoods, {
      params,
    });
  },
  getRemoveGoods(params) {
    return axios.get(base.removeGoods, {
      params,
    });
  },
  getupdataGoods(params) {
    return axios.get(base.updataGoods, {
      params,
    });
  },
 
};

export default api;
